/**
 * Created by DuHuiling on 2017/4/25.
 */
var Password = require('../../../../src/libs/password');
var Form = require('../../../../src/libs/form');
var FormItem = require('../../../../src/libs/form-item');
var Input = require('../../../../src/libs/input');
var GetCode = require('../../../../src/libs/get-code');
var ChangePwd = React.createClass({
    getDefaultProps:function(){
        return{
            title:this.props.title,
            warmTips:this.props.warmTips?this.props.warmTips:""
        }
    },
    resetForm:function(){
        this.refs.changeForm.reset();
        this.refs[this.props.getCode.dmbind].stopCount();
    },
    componentDidMount:function(){
        var _this = this;
        UEventHub.on('getcode',function(v){
            var dmbind = _this.props.getCode.dmbind;
            if(v == _this.props.getCode){
                _this.refs[dmbind].toCount();
            }
        }.bind(this));
    },
    render:function(){
        return(
            <div>
                <div className="alert-title"><b></b>{this.props.title}<b></b></div>
                <div className="alert-content">
                    {this.props.warmTips ?
                        <div className="tips fc-main"><i className="iconfont icon-tips"></i>{this.props.warmTips}</div> : ""
                    }
                    <div className="form">
                        <Form ref="changeForm">
                            <FormItem label={<div><b>*</b>{this.props.oldPwd.label}</div>} id={this.props.oldPwd.id} dmbind={this.props.oldPwd.dmbind}>
                                <Password className="ucs-input" name={this.props.oldPwd.name} placeholder={this.props.oldPwd.placeholder} dmbind={this.props.oldPwd.dmbind}/>
                            </FormItem>
                            <FormItem label={<div><b>*</b>{this.props.newPwd.label}</div>} id={this.props.newPwd.id} dmbind={this.props.newPwd.dmbind}>
                                <Password className="ucs-input" name={this.props.newPwd.name} placeholder={this.props.newPwd.placeholder} dmbind={this.props.newPwd.dmbind}/>
                            </FormItem>
                            <FormItem label={<div><b>*</b>{this.props.checkNewPwd.label}</div>} id={this.props.checkNewPwd.id} dmbind={this.props.checkNewPwd.dmbind}>
                                <Password className="ucs-input" name={this.props.checkNewPwd.name} placeholder={this.props.checkNewPwd.placeholder} dmbind={this.props.checkNewPwd.dmbind}/>
                            </FormItem>
                            <FormItem label={<div><b>*</b>{this.props.phoneCode.label}</div>} id={this.props.phoneCode.id} name={this.props.phoneCode.name} dmbind={this.props.phoneCode.dmbind}>
                                <Input id={this.props.phoneCode.id} name={this.props.phoneCode.name} className="ucs-input ucs-input-code" placeholder={this.props.phoneCode.placeholder} value={this.props.phoneCode.value} dmbind={this.props.phoneCode.dmbind}/>
                                <GetCode ref={this.props.getCode.dmbind} dmbind={PageDM.phoneCode.dmbind} className="btn btn-code" count={this.props.getCode.count} onClick={this.props.getCode.onClick}/>
                            </FormItem>
                        </Form>
                    </div>
                </div>
            </div>
        )
    }
});
module.exports = ChangePwd;